package com.jet.stock.inner;

import com.jet.core.result.ResultJson;
import com.jet.stock.domain.dto.StockSpuDto;
import com.jet.stock.service.StockSpuService;
import org.springframework.web.bind.annotation.*;

/**
 * @author dcl
 * @since 2025/2/21 13:22
 */
@RestController
@RequestMapping("/inner/stock-spu")
public class InnerStockSpuController {

    private final StockSpuService stockSpuService;

    public InnerStockSpuController(StockSpuService stockSpuService) {
        this.stockSpuService = stockSpuService;
    }

    @PostMapping
    public ResultJson<String> async(@RequestParam long merchantNo, @RequestBody StockSpuDto dto) {
        stockSpuService.batchEdit(merchantNo, dto);
        return ResultJson.ok();
    }

    @PutMapping("/status")
    public ResultJson<Void> asyncStatus(@RequestParam long merchantNo,
                                        @RequestParam String spuId,
                                        @RequestParam int status) {
        stockSpuService.batchEdit(merchantNo, spuId, status);
        return ResultJson.ok();
    }

    @DeleteMapping
    public ResultJson<Void> deleteBySpuId(@RequestParam long merchantNo, @RequestParam String spuId) {
        stockSpuService.deletedBySpuId(merchantNo, spuId);
        return ResultJson.ok();
    }
}
